package com.seguriapp.dao;

import android.content.ContentValues;
import android.net.Uri;

import com.seguriapp.entities.ComplaintEntity;
import com.seguriapp.providers.SeguriappProvider;
import com.seguriapp.util.Constants;

public class ComplaintDao {

	public static final String TABLE_NAME = "Complaint";
	public static final String COL_ID = "_id";
	public static final String COL_CID = "idComplaint";
	public static final String COL_NAME = "names";
	public static final String COL_LASTNAME = "lastnames";
	public static final String COL_DNI = "dni";
	public static final String COL_SEX = "sex";
	public static final String COL_PHONE = "phone";
	public static final String COL_AGE = "age";
	public static final String COL_DESCRIPTION = "description";
	public static final String COL_STATE = "state";
	public static final String COL_DATEREG = "datereg";
	public static final String COL_DATECOMPLAINT = "datecomplaint";
	public static final String COL_ADDRESS = "address";

	// Content Provider constants
	public static final Uri CONTENT_URI = Uri.parse("content://"
			+ SeguriappProvider.AUTHORITY + "/" + TABLE_NAME);
	public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.seguriapp.complaints";

	// Create the table
	protected static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS "
			+ TABLE_NAME + " (" + COL_ID + " " + Constants.INTEGER
			+ " PRIMARY KEY," + COL_CID + " " + Constants.INTEGER + ", "
			+ COL_NAME + " " + Constants.TEXT + ", " + COL_LASTNAME + " "
			+ Constants.TEXT + ", " + COL_DNI + " " + Constants.INTEGER + ", "
			+ COL_SEX + " " + Constants.TEXT + ", " + COL_PHONE + " "
			+ Constants.BOOLEAN + ", " + COL_AGE + " " + Constants.INTEGER
			+ ", " + COL_DESCRIPTION + " " + Constants.TEXT + ", " + COL_STATE
			+ " " + Constants.TEXT + ", " + COL_DATEREG + " " + Constants.TEXT
			+ ", " + COL_DATECOMPLAINT + " " + Constants.TEXT + ", "
			+ COL_ADDRESS + " " + Constants.TEXT + ")";

	public static ContentValues contentValuesToInsert(
			final ComplaintEntity complaint) {
		final ContentValues values = new ContentValues();
		values.put(COL_CID, complaint.getComplaintId());
		values.put(COL_NAME, complaint.getNames());
		values.put(COL_LASTNAME, complaint.getLastnames());
		values.put(COL_DNI, complaint.getDni());
		values.put(COL_SEX, complaint.getSex());
		values.put(COL_PHONE, complaint.getPhone());
		values.put(COL_AGE, complaint.getAge());
		values.put(COL_DESCRIPTION, complaint.getDescription());
		values.put(COL_STATE, complaint.getState());
		values.put(COL_DATEREG, complaint.getDateReg());
		values.put(COL_DATECOMPLAINT, complaint.getDateComplaint());
		values.put(COL_ADDRESS, complaint.getAddress());
		return values;
	}
}
